import { defineConfig } from 'astro/config';

import mdx from '@astrojs/mdx';
import svelte from "@astrojs/svelte";
import sitemap from "@astrojs/sitemap";
import UnoCSS from 'unocss/astro';
import AutoImport from 'unplugin-auto-import/astro';
import prefetch from '@astrojs/prefetch';
// import nodejs from '@astrojs/node';
import Prism from '@astrojs/markdown-remark';
import autolinkHeadings from 'remark-autolink-headings';
// https://astro.build/config

// ! 配置文件
// ? https://astro.build

// https://astro.build/config
export default defineConfig({
  experimental: {
    assets: true
  },
  site: 'https://astro.youling.io/',
  integrations: [
    UnoCSS({
      configFile: '../unocss.config.ts',
    }),
    prefetch(), sitemap(), mdx({
      extendMarkdownConfig: false,
      smartypants: true,
      gfm: true
    }), svelte(), AutoImport({
      imports: ['svelte', 'svelte/store'],
      dts: './src/auto-imports.d.ts'
    })],
  markdown: {
    // remarkPlugins: [Prism],
    gfm: true
  },
  // todo 服务端渲染时开启
  // 静态输出时候 关闭
  // output: "server",
  // build: {
  //   server: './dist/server/',
  //   client: './dist/client/',
  //   serverEntry: 'entry.mjs',

  // },
  vite: {
    ssr: {
      noExternal: ['three', 'troika-three-text'],
      external: ['svgo']
    }
    // build: {
    //   rollupOptions: {
    //     output: {
    //       entryFileNames: 'entry.[hash].js',
    //       chunkFileNames: 'chunks/chunk.[hash].js',
    //       assetFileNames: 'assets/asset.[hash][extname]',
    //     },
    //   },
    // },
  }
});
